library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity reg16 is
port ( clk, reset, inc : in
std_logic;
load
: in std_logic;
data_in
: in std_logic_vector (15 downto 0);
q :
out std_logic_vector (15 downto 0)
);
end reg16;
architecture arch of reg16 is
signal qreg : std_logic_vector (15 downto 0);
begin
process (clk, reset)
begin
if (reset = '0') then
qreg <= X"0000";
else
if rising_edge(clk) then
if (load = '1') then
qreg <= data_in;
else
if (inc = '1') then
qreg <= qreg + '1';
end if;
end if;
end if;
end if;
q <= qreg;
end process;
end arch;
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity vector is
generic (length : natural := 8);
port ( data_in
: in std_logic_vector (length downto 1);
dout
: out std_logic_vector (length downto 1)
);
end vector;
architecture arch of vector is
begin
process (data_in)
variable reg : std_logic_vector (length downto 1);
begin
reg := (others=>'0');
for i in 1 to length loop
if (data_in(i) = '1') then
reg := '1'
& reg(length downto 2);
end if;
end loop;
dout <= reg;
end process;
end arch;
--------------------------------------------------------------------------------------------------------------------------------------
Instructions: For all the questions you are required to submit VHDL codes & test bench simulation...
Write a test bench for the following VHDL code -------------------------------------------------------------------------------------------------------------------------------- LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY registern IS GENERIC (N: INTEGER :=4); -- INTEGER=32, 16, ….. PORT (D : IN STD_LOGIC_VECTOR (N-1 downto 0); clk, reset, Load : IN STD_LOGIC ; Q : OUT STD_LOGIC_VECTOR (N-1 downto 0 )) ; END registern; ARCHITECTURE behavior OF registern IS BEGIN PROCESS (clk) BEGIN IF clk' EVENT AND clk='1' THEN IF (reset ='0') THEN --synchronous reset Q<=(OTHERS=>’0’); ELSIF (L ='0') THEN Q<=D;...
Assignment: Implement an 8 bit register in VHDL/Verilog using Model Sim software. Show two test cases for data read and write into the register. The register has an enable and reset signal. When the reset is high the register should be cleared. When the enable is high and reset is low, data should be written into the register. Hint: The demo code shown below has the implementation for a 4-bit register that can be used as an example. library ieee;...
Please Write it in VHDL and complete the following code
Create an entity called "regs" where you infer a true dual port (both ports can independently either read or write to any location) memory consisting of 32 16-bit words (64 Bytes). It should have the following black box interface and behavior: entity regs is port clk, en, rst in std_logic; İdl, İd2 : in std logic vector (4 downto 0); __ Addresses wr_enl, wr_ en2 in std logic dinl, din2...
Lab Description Follow the instructions in the lab tasks below to behaviorially create and simulate a flip-flop. Afterwards, you will create a register and use your ALU from Lab 3 to create an accumulator-based processor. This will act ike a simple processor; the ALU will execute si operations and each result will be stored in the register. In an accumulator, the value of the register will be updated with each operation; the register is used as an input to the...