Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Computer Architecute lite Single cycle MIPS design problem

Status
Not open for further replies.

stely000

Newbie level 4
Joined
Apr 20, 2012
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,374
Hello,
I'm designing a lite MIPS that supports base addressing jumps, and some basic operation(including imm) like computing an address and writing/reading from that address etc.

For the clock signal a mono pulse generator is used and a BCD display to show different result.
1.png this is the data path that i'm trying to implement.

Until now i've manage to implement this part: 2.png

My problem is the DataMemory(DMEM in code). I can't get it to work. I don't know why.

The code for the entire entity is this:
Code:
----------------------ENTITY-----------------------------
entity test_env is
	
    Port ( clk : in  STD_LOGIC;
           btn : in  STD_LOGIC_VECTOR (3 downto 0);
           sw : in  STD_LOGIC_VECTOR (6 downto 0);
           led : out  STD_LOGIC_VECTOR (7 downto 0);
           an : out  STD_LOGIC_VECTOR (3 downto 0);
           cat : out  STD_LOGIC_VECTOR (6 downto 0);
           dp : out  STD_LOGIC);
end test_env;
---------------------END---------------------------------


architecture Behavioral of test_env is
	
	----------------------MPG component-------------------
	component mpg is
   Port ( clk : in  STD_LOGIC;
           btn : in  STD_LOGIC_VECTOR (3 downto 0);
           step : out  STD_LOGIC_VECTOR (3 downto 0));
	end component;
	-------------------------END--------------------------
	
	----------------------SSD component-------------------
	component ssd is
    Port ( 	d1 : in std_logic_vector(3 downto 0);
				d2 : in std_logic_vector(3 downto 0);
				d3 : in std_logic_vector(3 downto 0);
				d4 : in std_logic_vector(3 downto 0);
            anod : out  STD_LOGIC_VECTOR (3 downto 0);
            catod : out  STD_LOGIC_VECTOR (6 downto 0);
            clk : in  STD_LOGIC);
	end component;
	-------------------------END--------------------------
	
	
	-------------------REGISTER component-----------------
	component reg_file is 
	port ( 	clk : in std_logic; 
				ra1 : in std_logic_vector (3 downto 0); 
				ra2 : in std_logic_vector (3 downto 0); 
				wa : in std_logic_vector (3 downto 0); 
				wd : in std_logic_vector (7 downto 0); 
				wen : in std_logic; 
				rd1 : out std_logic_vector (7 downto 0); 
				rd2 : out std_logic_vector (7 downto 0)); 
	end component;
	-------------------------END--------------------------
	
	
	-------------------ALU component----------------------	
	component cascade_alu is
	generic ( 
		width : natural range 4 to 16 := 8 
		);
		port( 
				a 			: in std_logic_vector(width - 1 downto 0);
				b 			: in std_logic_vector(width - 1 downto 0);
				c_ainv 	: in std_logic; 
				c_binv 	: in std_logic; 
				c_aluop	: in std_logic_vector(3 downto 0); 
				c_ovf		: out std_logic;
				c_zero 	: out std_logic;
				res		: out std_logic_vector(width - 1 downto 0)
		); 
	end component;
	-------------------------END--------------------------
	
	-----------------------SIGNALS------------------------
	signal rcnt 	: std_logic_vector(7 downto 0);

	
	
	type mem is array (0 to 2**8-1) of std_logic_vector (15 downto 0); 
	type ram_type is array (0 to 2**8-1) of std_logic_vector (7 downto 0);
	
	
	signal pc_count: std_logic_vector(7 downto 0);
	
	signal step 	: std_logic_vector(3 downto 0);
	signal step_d 	: std_logic_vector(3 downto 0);
		

	signal op 			:  std_logic_vector (3 downto 0); 
	signal ra1 			:  std_logic_vector (3 downto 0); 
	signal ra2 			:  std_logic_vector (3 downto 0); 
	signal wa 			:  std_logic_vector (3 downto 0); 
	signal wd 			:  std_logic_vector (7 downto 0); 
	signal rd1 			:  std_logic_vector (7 downto 0); 
	signal rd2 			:  std_logic_vector (7 downto 0); 
	signal imm			:  std_logic_vector (7 downto 0); 
	
	signal disp 		: std_logic_vector(15 downto 0);
	signal rom_d 		: std_logic_vector(15 downto 0);

	
	-- control signals
	signal regWrite	: std_logic;
	signal regWritei	: std_logic;
	--control signals for ALU--
		--NOTE: caryy in nu trebuie, e aceeasi cu b_inv--
	signal a_inv,b_inv,ovf,zero:std_logic;
	signal res:std_logic_vector(7 downto 0);
	
	--ALU src--
	signal alu_src:std_logic;
	signal data2:std_logic_vector(7 downto 0);
	
	--RegDst--
	signal RegDst: std_logic;
	
	attribute equivalent_register_removal: string;
	
	attribute equivalent_register_removal of rom_d : signal is "no";
	
	
	-- DMEM --
	signal memWrite:std_logic;
	signal temp:std_logic_vector(7 downto 0);
	signal DMEM : ram_type:=(	x"44",
										x"44",
										x"44",
										x"44",
										x"44",
										x"44",
										x"44",
										x"44",
										others => x"11"
									);
	signal we:std_logic;
	attribute equivalent_register_removal of temp : signal is "no";
	
	signal ROM 		: mem := (
		x"0005",
		x"0019",
		x"0024",
		x"0035",
		x"0049",
		x"0054",
		x"0005",
		x"0015",
		x"0025",
		x"0035",
		x"0046",
		x"0056",
		x"0036",
		x"0046",
		x"0056",
		x"0066",
		x"0076",
		x"0086",
		x"0096",
		x"0006",
		x"0017",
		others => x"0000"
	);


begin
	
	mpg1: mpg 
	Port map ( 
		clk => clk, 
		btn => btn, 
		step => step 
		);
		
	ssd1: ssd
	Port map ( 
		d1 => disp(15 downto 12),
		d2 => disp(11 downto 8),
		d3 => disp (7 downto 4),
		d4 => disp (3 downto 0),
      anod => an,
      catod => cat,
      clk =>clk
		);
		
	ALU: cascade_alu
	Port map (
				a 			=>rd1,
				b 			=>data2,	--rd2 sau imm
				c_ainv 	=>a_inv,
				c_binv 	=>b_inv,
				c_aluop	=>op,
				c_ovf		=>ovf,
				c_zero 	=>zero,
				res		=>res
				);
				
	process(clk)
	begin
		if rising_edge(clk) then
			step_d <= step;
		end if;
	end process;
	
	-- program counter
	process(clk)
	begin
		if rising_edge(clk) then
			if step_d(1) = '1' then
				pc_count <= pc_count + 1;
			end if;
		end if;
	end process;
	
		-- temp counter for DMEM
	process(clk)
	begin
		if rising_edge(clk) then
			if (step_d(2) or step_d(3)) = '1' then
				rcnt <= rcnt + 1;
			end if;
		end if;
	end process;
	
	-- rom
		rom_d <= ROM(conv_integer(pc_count));
		
	--DMEM--
	process (clk,rcnt,rd2,we,memWrite)
		begin
			if rising_edge(clk) then
				if we ='1' then
						if memWrite = '1' then 
							DMEM(conv_integer(res)) <= rd2; 
						else
							temp<= DMEM( conv_integer(rcnt));
							end if;
				end if;
			end if;
	end process;
	
	
	led <= rcnt;

	
	-- instruction decode
	op 	<= rom_d(15 downto 12);
	ra1 	<= rom_d(11 downto 8);
	ra2 	<= rom_d(7 downto 4);
	imm 	<= "0000" & rom_d(3 downto 0);
	
	-- RegDst MUX --
	process(rom_d(3 downto 0), imm,RegDst,wa,ra2,pc_count)
		begin
			if RegDst ='1' then
				wa<=rom_d(3 downto 0);
			else
				wa<=ra2;
			end if;
	end process;
	
	-- reg file
	reg_file1: reg_file
	Port map (
		clk => clk, 
		ra1 => ra1, 
		ra2 => ra2, 
		wa => wa, 
		wd => wd, 
		wen => regWrite,
		rd1 => rd1, 
		rd2 => rd2
	);
	
	
	-- control unit --
	process(op,pc_count)
	begin
		case op is 
			-- add
			when "0000" 	=> regWritei <= '0';
			-- addi
			when "0001" 	=> regWritei <= '0';
			when others 	=> regWritei <= '0';
		end case;
	end process;
	
	--Alu src MUX--
	process(alu_src,imm,rd2,pc_count)
	begin
		if alu_src ='1' then
				data2<=imm;
		elsif alu_src = '0' then
				data2<=rd2;
		end if;
	end process;

	process(clk)
	begin	
		if rising_edge(clk) then
			if step(1) = '1' then
				regWrite <= regWritei;
			else
				regWrite <= '0';
			end if;
		end if;
	end process;
	
	
	-- To BCD --
	process(sw,rom_d,rd1,rd2,imm,wd,pc_count,temp,res)
	begin
		case sw(1 downto 0) is
			when "00"	=> disp <= rom_d;
			when "01"	=> disp <= rd1 & rd2;
			when "10"	=> disp <= "00000000"&res;--"0000"&ra1 &"0000"&ra2;
			when others => disp <= "00000000"&temp;--x"00" & wd;
		end case;
	end process;
	
	dp <= zero;
	a_inv<=sw(2);
	alu_src<=sw(3);
	RegDst<=sw(4);
	memWrite<=sw(5);
	we<=sw(6);
	b_inv<=step_d(0);
	
	
	
end Behavioral;

I think my problem is in this section:

Code:
--DMEM--
	process (clk,rcnt,rd2,we,memWrite)
		begin
			if rising_edge(clk) then
				if we ='1' then
						if memWrite = '1' then 
							DMEM(conv_integer(res)) <= rd2; 
						else
							temp<= DMEM( conv_integer(rcnt));
							end if;
				end if;
			end if;
	end process;

All the components are tested and work properly. The signals res(the address) and rd2(the data) have the correct values.

When I try to read from DMEM to see if i write properly in DMEM the output(temp) is 0. This can be 2 things: 1) I don;t write correctly in DMEM. 2) I don't read correctly form DMEM. This might be because I haven't design the RAM DMEM properly.

The DMEM block shoud have 2 signals for memory write and memory read, an address(on 8 bits) write data(on 8 bits) and a read data(on 8 bits).

The warnings and INFO are here:


All Current Messages V 20. apr. 11:46:56 2012

--------------------------------------------------------------------------------

Program All Current Messages - Errors, Warnings, and Infos New
xst WARNING Xst:646 - Signal <set<6:0>> is assigned but never used. This unconnected signal will be trimmed during the optimization process.
xst WARNING Xst:646 - Signal <ovf> is assigned but never used. This unconnected signal will be trimmed during the optimization process.
xst WARNING Xst:1781 - Signal <ROM> is used but never assigned. Tied to default value.
xst INFO Xst:2679 - Register <regWrite> in unit <test_env> has a constant value of 0 during circuit operation. The register is replaced by logic.
xst INFO Xst:1561 - "D:/CA/L1/ssd.vhd" line 63: Mux is complete : default of case is discarded
xst INFO Xst:3031 - HDL ADVISOR - The RAM <Mram_reg_file> will be implemented on LUTs either because you have described an asynchronous read or because of currently unsupported block RAM features. If you have described an asynchronous read, making it synchronous would allow you to take advantage of available block RAM resources, for optimized device usage and improved timings. Please refer to your documentation for coding guidelines.
xst INFO Xst:3031 - HDL ADVISOR - The RAM <Mram_reg_file_ren> will be implemented on LUTs either because you have described an asynchronous read or because of currently unsupported block RAM features. If you have described an asynchronous read, making it synchronous would allow you to take advantage of available block RAM resources, for optimized device usage and improved timings. Please refer to your documentation for coding guidelines.
xst INFO Xst:3040 - The RAM <Mram_DMEM> will be implemented as a BLOCK RAM, absorbing the following register(s):
map INFO LIT:243 - Logical network reg_file1/Mram_reg_file1/SPO has no load.
map INFO LIT:395 - The above info message is repeated 15 more times for the following (max. 5 shown): reg_file1/Mram_reg_file4/SPO, reg_file1/Mram_reg_file2/SPO, reg_file1/Mram_reg_file3/SPO, reg_file1/Mram_reg_file5/SPO, reg_file1/Mram_reg_file6/SPO To see the details of these info messages, please use the -detail switch.
map INFO MapLib:562 - No environment variables are currently set.
map INFO LIT:244 - All of the single ended outputs in this design are using slew rate limited output drivers. The delay on speed critical single ended outputs can be dramatically reduced by designating them as fast outputs.
par INFO Par:282 - No user timing constraints were detected or you have set the option to ignore timing constraints ("par -x"). Place and Route will run in "Performance Evaluation Mode" to automatically improve the performance of all internal clocks in this design. Because there are not defined timing requirements, a timing score will not be reported in the PAR report in this mode. The PAR timing summary will list the performance achieved for each clock. Note: For the fastest runtime, set the effort level to "std". For best performance, set the effort level to "high".
par INFO Timing:2761 - N/A entries in the Constraints List may indicate that the constraint is not analyzed due to the following: No paths covered by this constraint; Other constraints intersect with this constraint; or This constraint was disabled by a Path Tracing Control. Please run the Timespec Interaction Report (TSI) via command line (trce tsi) or Timing Analyzer GUI.
par INFO Timing:2761 - N/A entries in the Constraints List may indicate that the constraint is not analyzed due to the following: No paths covered by this constraint; Other constraints intersect with this constraint; or This constraint was disabled by a Path Tracing Control. Please run the Timespec Interaction Report (TSI) via command line (trce tsi) or Timing Analyzer GUI.
par INFO Timing:2761 - N/A entries in the Constraints List may indicate that the constraint is not analyzed due to the following: No paths covered by this constraint; Other constraints intersect with this constraint; or This constraint was disabled by a Path Tracing Control. Please run the Timespec Interaction Report (TSI) via command line (trce tsi) or Timing Analyzer GUI.
trce INFO Timing:2698 - No timing constraints found, doing default enumeration.
trce INFO Timing:2752 - To get complete path coverage, use the unconstrained paths option. All paths that are not constrained will be reported in the unconstrained paths section(s) of the report.
trce INFO Timing:3339 - The clock-to-out numbers in this timing report are based on a 50 Ohm transmission line loading model. For the details of this model, and for more information on accounting for different loading conditions, please see the device datasheet.
trce INFO Timing:3390 - This architecture does not support a default System Jitter value, please add SYSTEM_JITTER constraint to the UCF to modify the Clock Uncertainty calculation.
trce INFO Timing:3389 - This architecture does not support 'Discrete Jitter' and 'Phase Error' calculations, these terms will be zero in the Clock Uncertainty calculation. Please make appropriate modification to SYSTEM_JITTER to account for the unsupported Discrete Jitter and Phase Error.
 

Attachments

  • 1.bmp
    3 MB · Views: 86
  • 2.bmp
    3 MB · Views: 88

Hi,

Have you tried using a signal trace tool like Modelsim, VCS, Questa....etc to see how the signal are changing?
(Highly recommended) (If you have then attach the waveforms, they would be mighty useful)
i) in your definition of DMEM you have hard coded some values.
Depending on the synthesizer your using, I would prefer any hard coding, inside a process as a FSM

ii) As much as synchronous circuitry is great keeping i.e. getting everything done with the clock.
You might want to reset the DMEM with your rest asynchronously (it is allowed and legal to design!)

iii) Can you also attach the testbench output for sw(5) or the code your have written for it.
( i presume you have checked sw for the signal enable to memwrite)
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top