Forum Discussion

AP3's avatar
AP3
Icon for New Contributor rankNew Contributor
7 years ago

Counter : Using NIOS II and WIZNET 5300

First time i am working with the design using Ethernet (Wiznet W5300). So i need your help from guys. Initially i have taken the exercise that I need run the 8-bit counter in NIOS using W5300.

Counter code as below

module counter
#(parameter WIDTH=8)
(
	input clk, enable, rst_n,
	output reg [WIDTH-1:0] count
);
 
	always @ (posedge clk or negedge rst_n)
	begin
		if (~rst_n)
			count <= 0;
		else if (enable == 1'b1)
			count <= count + 1;
	end
 
endmodule

Main Function:

library ieee;
use ieee.std_logic_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
 
 
entity Instanstation is
	port
	(
		count 			   : out std_logic_vector(7 downto 0); -- 120 will be direct , group (T) 8 will be TTL
      enable       : in  std_logic;		
		clk           		: in  std_logic
	);
	
end Instanstation;
 
architecture behav of Instanstation is
signal WD_nRSTs			: std_logic;
signal RPC_OUT_AUX	   : std_logic_vector(7 downto 0);
component counter is
	port
	(
		clk		: in std_logic; -- 120 will be direct , group (T) 8 will be TTL
		enable   : in  std_logic;
		rst_n	   : in std_logic;		
		count 	: out std_logic_vector (7 downto 0));
 
	end component;	
	begin
count(7 downto 0) <= RPC_OUT_AUX(7 downto 0);
 
end behav;

Can anyone suggest me whether my design flow is right or wrong. Then how to interface the NIOS and WIZNET.

Altera : Top file

3 Replies