⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scinode2.vhd

📁 VHDL 关于2DFFT设计程序 u scinode1 &#8764 scinode9.vhd: Every SCI node RTL vhdl code. The details can be
💻 VHD
📖 第 1 页 / 共 4 页
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_signed.all;

entity scinode2 is
port( reset, clk:	in std_logic;
      vertical_data_in:	in std_logic_vector(15 downto 0);
      horizontal_data_in:	in std_logic_vector(15 downto 0);
      vertical_data_out:	out std_logic_vector(15 downto 0);
      horizontal_data_out:	out std_logic_vector(15 downto 0);
      global_cnt:			in integer range 0 to 110);
end scinode2;

architecture spec of scinode2 is
type PACKET_SIZE is array (0 to 4) of std_logic_vector(15 downto 0);	--five 16-bit entry, and the field is specified following
type FIFO is array( 0 to 3) of PACKET_SIZE;
signal bypass_fifo: FIFO;
type REC_QUEUE_ENTRY_SIZE is array(0 to 2) of std_logic_vector(15 downto 0);
type REC_QUEUE is array (0 to 3) of REC_QUEUE_ENTRY_SIZE;	--every queue have four packet entry
signal req_rec_q, res_rec_q: 	REC_QUEUE;
type XMIT_QUEUE_ENTRY_SIZE is array(0 to 3) of std_logic_vector(15 downto 0);
type XMIT_QUEUE is array (0 to 3) of XMIT_QUEUE_ENTRY_SIZE;
signal req_xmit_q, res_xmit_q:	XMIT_QUEUE;
--signal processing_data: PACKET_SIZE;			--processor manupulate the packet;
signal data_in, data_out:	std_logic_vector(15 downto 0);
alias targetId: std_logic_vector(15 downto 0) is data_in;	--first 8 bit to indicate the processor
																		--second 8 bit to indicate the offset address
alias command: std_logic_vector(1 downto 0) is data_in(1 downto 0);	--only 5 type command: req_send, req_echo, res_send, res_echo, idle
alias sourceId: std_logic_vector(15 downto 0) is data_in;	--first 8 bit to indicate the processor, second 8 bit indicate the offset
alias Data: std_logic_vector(15 downto 0) is data_in;
alias AddressOffset: std_logic_vector(4 downto 0) is data_in(4 downto 0);	--address_offset
signal req_rec_q_first: integer range 0 to 3;	--indicate the first entry of fifo
signal req_rec_q_last: 	integer range 0 to 3;	--indicate the last entru of fifo
signal res_rec_q_first, res_rec_q_last:	integer range 0 to 3;
signal req_xmit_q_first, req_xmit_q_last:	integer range 0 to 3;
signal res_xmit_q_first, res_xmit_q_last:	integer range 0 to 3;
signal bypass_fifo_first, bypass_fifo_last: integer range 0 to 3;
signal counter: integer range 0 to 5;			--count the half word from reciever queue
												--count the half word from xmiter queue
signal priority_flg: integer range 0 to 3;		--select the mux output
signal xmit_r_r_flg: std_logic;					--select the xmit output is from requset queue or response queue
signal where_to_store:	integer range 0 to 4;	--select req_rec_q or res_rec_q or bypass_fifo
signal where_to_send:	integer range 0 to 4;	--0 indicate req_q, 1 indicate res_q, 2 indicate bypass_fifo, 3 indicate none to send
constant AddressId: std_logic_vector(7 downto 0) := "00000010";
type FLAG is array(0 to 3) of integer range 0 to 2;
signal req_xmit_q_flg: FLAG;					--1 indicate pending, 2 indicate resend the packet
signal res_xmit_q_flg: FLAG;					--1 indicate pending, 2 indicate resend the packet
signal echo_flag: integer range 0 to 2;			--indicate if the packet is echo or not!!
signal echo_sourceId: std_logic_vector(7 downto 0);
signal req_rec_q_full, res_rec_q_full:	std_logic;
--signal req_xmit_q_full, res_xmit_q_full:	std_logic;	--flag set when queue is full
signal stripper_q:	XMIT_QUEUE;					--the queue is to keep the echo resend packet when the reciever queue is full
signal stripper_q_first, stripper_q_last: integer range 0 to 3;
type REG_FILE is array(0 to 8) of std_logic_vector(7 downto 0);
signal a, b: REG_FILE;							--a,b for each x
signal process_priority:	integer range 0 to 2;--0 none, 1 indicate req_rec_q, 2 indicate res_rec_q
signal a_tmp, b_tmp: REG_FILE;
signal bypass_fifo_ptr:		integer range 0 to 3;
constant w1_r: std_logic_vector(4 downto 0) := "01100";	--w(1) real part,0.766
constant w1_c: std_logic_vector(4 downto 0) := "10110";	--w(1) imaginary part,-0.643
constant w2_r: std_logic_vector(4 downto 0) := "00010";	--w(2) real part,0.174
constant w2_c: std_logic_vector(4 downto 0) := "10001";	--w(2) imaginary part,-0.985
constant w3_r: std_logic_vector(4 downto 0) := "11000";	--w(3) real part,-0.5
constant w3_c: std_logic_vector(4 downto 0) := "10011";	--w(3) imaginary part,-0.866
constant w4_r: std_logic_vector(4 downto 0) := "10001";	--w(4) real part,-0.94
constant w4_c: std_logic_vector(4 downto 0) := "11011";	--w(4) imaginary part,-0.342
constant w5_r: std_logic_vector(4 downto 0) := "10001";	--w(5) real part,-0.94
constant w5_c: std_logic_vector(4 downto 0) := "00101";	--w(5) imaginary part,0.342
constant w6_r: std_logic_vector(4 downto 0) := "11000";	--w(6) real part,-0.5
constant w6_c: std_logic_vector(4 downto 0) := "01101";	--w(6) imaginary part,0.866
constant w7_r: std_logic_vector(4 downto 0) := "00010"; --w(7) real part 0.174
constant w7_c: std_logic_vector(4 downto 0) := "01111";	--w(7) imaginary part,0.985
constant w8_r: std_logic_vector(4 downto 0) := "01100";	--w(8) real part,0.766
constant w8_c: std_logic_vector(4 downto 0) := "01010";	--w(8) imaginary part,0.643
type TMP_REG_FILE is array(0 to 8) of std_logic_vector(12 downto 0);
signal a_tmp1, b_tmp1: TMP_REG_FILE;

begin

process( reset, clk )
begin
	if( reset = '1' ) then
		bypass_fifo(0)(0) <= "1111111111111111";	bypass_fifo(0)(1) <= "1111111111111111";
		bypass_fifo(0)(2) <= "1111111111111111";	bypass_fifo(0)(3) <= "1111111111111111";
		bypass_fifo(0)(4) <= "1111111111111111";	bypass_fifo(1)(0) <= "1111111111111111";
		bypass_fifo(1)(1) <= "1111111111111111";	bypass_fifo(1)(2) <= "1111111111111111";
		bypass_fifo(1)(3) <= "1111111111111111";	bypass_fifo(1)(4) <= "1111111111111111";
		bypass_fifo(2)(0) <= "1111111111111111";	bypass_fifo(2)(1) <= "1111111111111111";
		bypass_fifo(2)(2) <= "1111111111111111";	bypass_fifo(2)(3) <= "1111111111111111";
		bypass_fifo(2)(4) <= "1111111111111111";	bypass_fifo(3)(0) <= "1111111111111111";
		bypass_fifo(3)(1) <= "1111111111111111";	bypass_fifo(3)(2) <= "1111111111111111";
		bypass_fifo(3)(3) <= "1111111111111111";	bypass_fifo(3)(4) <= "1111111111111111";		
		req_rec_q(0)(0) <= "0000000000000000";		req_rec_q(0)(1) <= "0000000000000000";
		req_rec_q(0)(2) <= "0000000000000000";		--req_rec_q(0)(3) <= "0000000000000000";
		req_rec_q(1)(0) <= "0000000000000000";		req_rec_q(1)(1) <= "0000000000000000";
		req_rec_q(1)(2) <= "0000000000000000";		--req_rec_q(1)(3) <= "0000000000000000";
		req_rec_q(2)(0) <= "0000000000000000";		req_rec_q(2)(1) <= "0000000000000000";
		req_rec_q(2)(2) <= "0000000000000000";		--req_rec_q(0)(3) <= "0000000000000000";
		req_rec_q(3)(0) <= "0000000000000000";		req_rec_q(3)(1) <= "0000000000000000";
		req_rec_q(3)(2) <= "0000000000000000";		--req_rec_q(1)(3) <= "0000000000000000";
		res_rec_q(0)(0) <= "0000000000000000";		res_rec_q(0)(1) <= "0000000000000000";
		res_rec_q(0)(2) <= "0000000000000000";		--res_rec_q(0)(3) <= "0000000000000000";
		res_rec_q(1)(0) <= "0000000000000000";		res_rec_q(1)(1) <= "0000000000000000";
		res_rec_q(1)(2) <= "0000000000000000";		--res_rec_q(1)(3) <= "0000000000000000";
		res_rec_q(2)(0) <= "0000000000000000";		res_rec_q(2)(1) <= "0000000000000000";
		res_rec_q(2)(2) <= "0000000000000000";		--res_rec_q(1)(3) <= "0000000000000000";
		res_rec_q(3)(0) <= "0000000000000000";		res_rec_q(3)(1) <= "0000000000000000";
		res_rec_q(3)(2) <= "0000000000000000";		--res_rec_q(1)(3) <= "0000000000000000";
		req_xmit_q(0)(0) <= "0000000000000000";		req_xmit_q(0)(1) <= "0000000000000000";
		req_xmit_q(0)(2) <= "0000000000000000";		req_xmit_q(0)(3) <= "0000000000000000";
		req_xmit_q(1)(0) <= "0000000000000000";		req_xmit_q(1)(1) <= "0000000000000000";
		req_xmit_q(1)(2) <= "0000000000000000";		req_xmit_q(1)(3) <= "0000000000000000";
		res_xmit_q(0)(0) <= "0000000000000000";		res_xmit_q(0)(1) <= "0000000000000000";
		res_xmit_q(0)(2) <= "0000000000000000";		res_xmit_q(0)(3) <= "0000000000000000";
		res_xmit_q(1)(0) <= "0000000000000000";		res_xmit_q(1)(1) <= "0000000000000000";
		res_xmit_q(1)(2) <= "0000000000000000";		res_xmit_q(1)(3) <= "0000000000000000";
		stripper_q(0)(0) <= "1111111111111111";		stripper_q(0)(1) <= "1111111111111111";
		stripper_q(0)(2) <= "1111111111111111";		stripper_q(0)(3) <= "1111111111111111";
		stripper_q(1)(0) <= "1111111111111111";		stripper_q(1)(1) <= "1111111111111111";
		stripper_q(1)(2) <= "1111111111111111";		stripper_q(1)(3) <= "1111111111111111";	
		stripper_q(2)(0) <= "1111111111111111";		stripper_q(2)(1) <= "1111111111111111";
		stripper_q(2)(2) <= "1111111111111111";		stripper_q(2)(3) <= "1111111111111111";	
		stripper_q(3)(0) <= "1111111111111111";		stripper_q(3)(1) <= "1111111111111111";
		stripper_q(3)(2) <= "1111111111111111";		stripper_q(3)(3) <= "1111111111111111";								
		counter <= 0;								
		priority_flg <= 0;							xmit_r_r_flg <= '0';
		req_rec_q_first <= 0;						req_rec_q_last <= 0;
		req_xmit_q_first <= 0;						res_xmit_q_first <= 0;
		bypass_fifo_first <= 0;						bypass_fifo_last <= 0;
		echo_flag <= 0;
		where_to_store <= 0;						where_to_send <= 0;
		req_rec_q_full <= '0';						res_rec_q_full <= '0';
		stripper_q_first <=  0;						stripper_q_last <= 0;
		a(0) <= "11111100";							a(1) <= "00001000";
		a(2) <= "11111011";							a(3) <= "00000011";
		a(4) <= "00000111";							a(5) <= "00000011";
		a(6) <= "00000101";							a(7) <= "11111111";
		a(8) <= "11111110";					
		b(0) <= "00000000";							b(1) <= "00000001";
		b(2) <= "11111001";							b(3) <= "11111100";
		b(4) <= "00000010";							b(5) <= "11111000";
		b(6) <= "11111000";							b(7) <= "00000001";
		b(8) <= "11111010";	
	elsif( rising_edge( clk ) ) then
--Xmiter segment code
		case counter is
		when 5 =>
			if( global_cnt = 0 ) then
				where_to_send <= 4;
				data_out <= "1111111111111111";
			elsif( priority_flg /= 3 and stripper_q( stripper_q_first )(0) /= "1111111111111111" ) then
				data_out <= stripper_q( stripper_q_first )(0);
				priority_flg <= 3;
				where_to_send <= 3;
			else
				case priority_flg is
				when 0 => 	--request queue's priority
					if( req_xmit_q_first /= req_xmit_q_last and req_xmit_q_flg( req_xmit_q_first ) /= 1 ) then		--resend the packet
						data_out <= req_xmit_q( req_xmit_q_first )(0);
						where_to_send <= 0;
						req_xmit_q_flg( req_xmit_q_first ) <= 1;
					elsif( res_xmit_q_first /= res_xmit_q_last and res_xmit_q_flg( res_xmit_q_first ) /= 1) then	--no req_xmit packet to send & verify if res_xmit queue resend?
						data_out <= res_xmit_q( res_xmit_q_first )(0);
						where_to_send <= 1;
						res_xmit_q_flg( res_xmit_q_first ) <= 1;
					elsif( bypass_fifo( bypass_fifo_first )(0) /= "1111111111111111" ) then
						data_out <= bypass_fifo( bypass_fifo_first )(0);
						where_to_send <= 2;
					else
						where_to_send <= 4;			--nothing to send, send idle packet
						data_out <= "1111111111111111";
					end if;
				when 1 =>	--response queue's priority
					if( res_xmit_q_first /= res_xmit_q_last and res_xmit_q_flg( res_xmit_q_first ) /= 1 ) then	--no req_xmit packet to send & verify if res_xmit queue resend?
						data_out <= res_xmit_q( res_xmit_q_first )(0);
						where_to_send <= 1;
						res_xmit_q_flg( res_xmit_q_first ) <= 1;
					elsif( bypass_fifo( bypass_fifo_first )(0) /= "1111111111111111" ) then
						data_out <= bypass_fifo( bypass_fifo_first )(0);
						where_to_send <= 2;
					elsif( req_xmit_q_first /= req_xmit_q_last and  req_xmit_q_flg( req_xmit_q_first ) /= 1 ) then	--the next want send packet, if 2 indicate none to send
						data_out <= req_xmit_q( req_xmit_q_first )(0);
						where_to_send <= 0;
						req_xmit_q_flg( req_xmit_q_first ) <= 1;
					else
						where_to_send <= 4;
						data_out <= "1111111111111111";
					end if;
				when 2 =>	--bypass_fifo's priority
					if( bypass_fifo( bypass_fifo_first )(0) /= "1111111111111111" ) then
						data_out <= bypass_fifo( bypass_fifo_first )(0);
						where_to_send <= 2;
					elsif( req_xmit_q_first /= req_xmit_q_last and  req_xmit_q_flg( req_xmit_q_first ) /= 1 ) then		--resend the packet
						data_out <= req_xmit_q( req_xmit_q_first )(0);
						where_to_send <= 0;
						req_xmit_q_flg( req_xmit_q_first ) <= 1;
					elsif( res_xmit_q_first /= res_xmit_q_last and res_xmit_q_flg( res_xmit_q_first ) /= 1 ) then	--no req_xmit packet to send & verify if res_xmit queue resend?
						data_out <= res_xmit_q( res_xmit_q_first )(0);
						where_to_send <= 1;
						res_xmit_q_flg( res_xmit_q_first ) <= 1;
					else
						where_to_send <= 4;
						data_out <= "1111111111111111";
					end if;
				when others =>
				end case;
			end if;
--			counter <= 0;
		when 0 =>
			if( global_cnt = 0 ) then
				where_to_send <= 4;
				data_out <= "1111111111111111";
			else		
				case where_to_send is
				when 0 =>				--send the request command field packet
					data_out <= req_xmit_q( req_xmit_q_first )(1);
				when 1 =>				--send the response command field packet
					data_out <= res_xmit_q( res_xmit_q_first )(1);
				when 2 =>				--bypass_fifo
					data_out <= bypass_fifo( bypass_fifo_first )(1);
				when 3 =>
					data_out <= stripper_q( stripper_q_first )(1);
				when others =>
					data_out <= "1111111111111111";
				end case;
			end if;
--			counter <= 1;
		when 1 =>
			if( global_cnt = 0 ) then
				where_to_send <= 4;
				data_out <= "1111111111111111";
			else
				case where_to_send is
				when 0 =>				--send request sourceId field packet
					data_out <= "00000000" & AddressId;
				when 1 =>				--send the response sourceId field packet
					data_out <= "00000000" & AddressId;
				when 2 =>				
					data_out <= bypass_fifo( bypass_fifo_first )(2);
				when 3 =>
					data_out <= stripper_q( stripper_q_first )(2);
				when others =>
					data_out <= "1111111111111111";			
				end case;
			end if;
--			counter <= 2;
		when 2 =>
			if( global_cnt = 0 ) then
				where_to_send <= 4;
				data_out <= "1111111111111111";
			else
				case where_to_send is
				when 0 =>				--send the request addressoffset field packet
					data_out <= req_xmit_q( req_xmit_q_first )(2);
				when 1 =>				--send the response addressoffset field packet
					data_out <= res_xmit_q( res_xmit_q_first )(2);
				when 2 =>				
					data_out <= bypass_fifo( bypass_fifo_first )(3);
					bypass_fifo_ptr <= bypass_fifo_first;
					if( bypass_fifo_first = 3 ) then
						bypass_fifo_first <= 0;
					else
						bypass_fifo_first <= bypass_fifo_first + 1;
					end if;
				when 3 =>
					data_out <= stripper_q( stripper_q_first )(3);
					stripper_q( stripper_q_first )(0) <= "1111111111111111";	stripper_q( stripper_q_first )(1) <= "1111111111111111";
					stripper_q( stripper_q_first )(2) <= "1111111111111111";	stripper_q( stripper_q_first )(3) <= "1111111111111111";
					if( stripper_q_first = 3 ) then
						stripper_q_first <= 0;
					else
						stripper_q_first <= stripper_q_first + 1;
					end if;
				when others =>
					data_out <= "1111111111111111";			
				end case;
			end if;
--			counter <= 3;
		when 3 =>
			if( global_cnt = 0 ) then
				where_to_send <= 4;
				data_out <= "1111111111111111";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -