Question

In: Electrical Engineering

Can someone create a Test bench for this 4 Bit USR code so that it can...

Can someone create a Test bench for this 4 Bit USR code so that it can shift left, shift right and Load. This is in VHDL. Please type out the code.

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


entity Uni_reg is
port( LR,SP,clk,clear,shL,shR: in std_logic; -- shL = shift left shR= shift right
Da,Db,Dc : in std_logic; --inputs for load
Qa,Qb,Qc : out std_logic); --out puts from the flipflops
end Uni_reg;


architecture Structural of Uni_reg is


signal lr1,lr2,sp1,sp2,R1,R2,R3 : std_logic;
signal L1,L2,L3,LOAD1,LOAD2,LOAD3:std_logic;
signal c1,c2,c3 : std_logic;
signal Qas,Qbs,Qcs : std_logic;


component andgate
port(a,b,c : in std_logic; z : out std_logic);
end component;


component orgate
port(a,b,c : in std_logic; z : out std_logic);
end component;


component notgate
port(a: in std_logic; z : out std_logic);
end component;


component Dflipflop
port(D,clk: in std_logic; Q: out std_logic);
end component;


begin


NOTGATE1: notgate port map (LR,lr1);--1st notgate for LEFT/RIGHT
NOTGATE2: notgate port map (lr1,lr2);--2nd notgate for LEFT/RIGHT
NOTGATE3: notgate port map (SP,sp1);--1st notgate for SERIAL/PARRALLEL
NOTGATE4: notgate port map (sp1,sp2);--2nd notgate for SERIAL/PARRALLEL


ANDGATE1: andgate port map (shR,sp2,lr2,R1); --for right shift of 1st bit
ANDGATE2: andgate port map (sp2,lr1,Qbs,L1); --for left shift of 1st bit
ANDGATE3: andgate port map (lr2,sp1,Da,LOAD1);--for load of 1st bit
ANDGATE4: andgate port map (Qas,sp2,lr2,R2); --for right shift of 2nd bit
ANDGATE5: andgate port map (sp2,lr1,Qcs,L2); --for left shift of 2nd bit
ANDGATE6: andgate port map (lr2,sp1,Db,LOAD2);--for load of 2nd bit
ANDGATE7: andgate port map (Qbs,sp2,lr2,R3); --for right 3rd bit
ANDGATE8: andgate port map (sp2,lr1,shL,L3); --for left 3rd bit
ANDGATE9: andgate port map (lr2,sp1,Dc,LOad3);--for loading 3rd bit


ORGATE1: orgate port map (R1,L1,LOAD1,c1);--for the 1st flipflop
ORGATE2: orgate port map (R2,L2,LOAD2,c2);--for the 2nd flipflop
ORGATE3: orgate port map (R3,L3,LOAD3,c3);--for the 3rd flipflop


FLIPFLOP1: Dflipflop port map (c1,clk,Qas);
FLIPFLOP2: Dflipflop port map (c2,clk,Qbs);
FLIPFLOP3: Dflipflop port map (c3,clk,Qcs);


process(clk,clear)
begin
if clear ='1' then
c1<='0';
elsif (clk'event and clk = '1') then
c1<=c1;
Qa <= c1;
end if;
end process;


process(clk,clear)
begin
if clear ='1' then
Qbs<='0';
elsif (clk'event and clk = '1') then
Qbs<= Qbs;
Qb <= Qbs;
end if;
end process;


process(clk,clear)
begin
if clear ='1' then
Qcs<='0';
elsif (clk'event and clk = '1') then
Qcs<=Qcs;
Qc <= Qcs;
end if;
end process;


end Structural;

Solutions

Expert Solution

--VHDL TestBench

library IEEE;

use IEEE.Std_logic_1164.all;

use IEEE.Numeric_Std.all;

entity Uni_reg_tb is

end;

architecture bench of uni_reg_tb is

component Uni_reg

port( LR,SP,clk,clear,shL,shR:in std_logic;

Da,Db,Dc : in std_logic;

Qa,Qb,Qc : out std_logic);

end component ;

signal LR,SP,clk,clear,shL,shR:std_logic;

signal Da,Db,Dc: std_logic;

signal qa,Qb,Qc: std_logic;

constant clock_period :time:-10n ;

signal stop_the _clock :boolean;

begin

uut: Uni_reg port map ( LR =>LR,

SP =>SP,

clk => clk,

clear => clear,

shL => shL,

shR =>shR,

Da => Da,

Db => Db,

Dc => Dc,

Qa => Qa,

Qb => Qb,

Qc => Qc);

stimulus : process

begin

-- put initialization code here

clear <='1' ;

wait for 5 ns;

clear <='0' ;

wait for 5 ns;

--Put test bech stimulus code here

stop_the_clock <=true;

wait;

end process;

clocking:process

begin

while not stop_the_clock loop

clk <='0', '1' after clock_period/2;

wait for clock_period;

end loop;

wait;

end process;

end ;

--configuration declaration

configuration cfg_Uni_reg_tb of Uni_reg_tb is  

for bench

for uut: Uni_reg

--default configuration

end for;

end for;

end cfg_Uni_reg_tb ;

configuration cfg_Uni_reg_tb_Structural of Uni_reg_tb is

for bench

for uut: uni_reg

use entity work.Uni_reg(Structural);

end for ;

end for;

end cfg_Uni_reg_tb_Structural;


Related Solutions

code an 8 bit LFSR random number generator in system verilog. Write a test bench, load...
code an 8 bit LFSR random number generator in system verilog. Write a test bench, load the seed 11111111, and generate the first 10 random numbers.
Can anyone write a Verilog code and a test bench for a universal shift register with...
Can anyone write a Verilog code and a test bench for a universal shift register with 4 bits using D flip flop? Thanks
make 4 bit universal shift register in vhdl plz include the test bench. I will rate
make 4 bit universal shift register in vhdl plz include the test bench. I will rate
can someone change this code so that timestandard can be calculated at the end of the...
can someone change this code so that timestandard can be calculated at the end of the code using the inputs n,RF,PFD, and the measured cycles, instead of being called from the beginning of the code using namespace std; float timestandard(float time, float rf, float pfd) { return((time / 100) * rf * (1 + pfd)); /* calculating the time standard using the given formula*/ } int main() { int n, rf, pfd, x; /* inputs are taken*/ cout << "****...
create a test bench for the following code: module signed_mult (out, clk, a, b); output [15:0]...
create a test bench for the following code: module signed_mult (out, clk, a, b); output [15:0] out; input clk; input signed [7:0] a; input signed [7:0] b; reg signed [7:0] a_reg; reg signed [7:0] b_reg; reg signed [15:0] out; wire signed [15:0] mult_out; assign mult_out = a_reg * b_reg; always@(posedge clk) begin a_reg <= a; b_reg <= b; out <=mult_out; end endmodule
Create a VHDL code of a 4 bit Counter using D flip flop and a Frequency...
Create a VHDL code of a 4 bit Counter using D flip flop and a Frequency Divider that provides the clock signal input for counter
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class...
Can someone fix this code so that it can count comparison and exchange? import java.util.Arrays; class Main { static int comparisons; static int exchanges; // Recursive function to perform insertion sort on sub-array arr[i..n] public static void insertionSort(int[] arr, int i, int n) { int value = arr[i]; int j = i; // Find index j within the sorted subset arr[0..i-1] // where element arr[i] belongs while (j > 0 && arr[j - 1] > value) { arr[j] = arr[j...
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the...
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the following with 4 bit inputs , and can be tested in on nexys 4 board This is to be implement on : ISE Design Suite - Xilinx /* ALU Arithmetic and Logic Operations ---------------------------------------------------------------------- |ALU_Sel| ALU Operation ---------------------------------------------------------------------- | 0000 | ALU_Out = A + B; ---------------------------------------------------------------------- | 0001 | ALU_Out = A - B; ---------------------------------------------------------------------- | 0010 | ALU_Out = A * B;...
How to validate Javascript form data? Here is the code. Can someone modify it so that...
How to validate Javascript form data? Here is the code. Can someone modify it so that all the information is validated? Thanks. <!DOCTYPE html> <html lang="en"> <head>    <title>Music Survey</title>    <meta charset="utf-8"> </head> <style>    legend { font-weight:bold;    }    </style> <body> <h1>Music Survey</h1> <form method="post" action=""> <label for="myname"><b>Name:</b></label>        <input type="text" name="myname" id="myname">        <br><br> <label for="myemail"><b>Email:</b></label>        <input type="email" name="myemail" id="myemail">        <br><br>   <fieldset> <legend>Select Your Favorite Types of Music:</legend> <input type="checkbox"...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT