The question is to use two different state assignments of your choice, synthesiz
ID: 3773080 • Letter: T
Question
The question is to use two different state assignments of your choice, synthesize the design of the following codes using Encounter RTL Compiler by Cadence ,
I have files for one state and testbenceh I need to use Encounter RTL Compiler by Cadence to get the testing waveforms and synthesized diagrams.
###1### (Code)
___________________________________________________________________
`timescale 1ns/1ns
module bcd2ex3_1 (clk, data_in, reset,data_out);
input clk, data_in, reset;
output reg data_out;
// Declare state register
reg [2:0]state;
// Declare states
parameter S0 = 0, S1 = 1, S2 = 2, S3 = 3,S4=4,S5=5,S6=7;
// Determine the next state synchronously, based on the
// current state and the input
always @ (posedge clk or posedge reset) begin
if (reset)
state <= S0;
else
case (state)
S0:
if (data_in)
begin
state <= S2;
end
else
begin
state <= S1;
end
S1:
if (data_in)
begin
state <= S4;
end
else
begin
state <= S3;
end
S2:
if (data_in)
begin
state <= S4;
end
else
begin
state <= S4;
end
S3:
if (data_in)
begin
state <= S5;
end
else
begin
state <= S5;
end
S4:
if (data_in)
begin
state <= S6;
end
else
begin
state <= S5;
end
S5:
if (data_in)
begin
state <= S0;
end
else
begin
state <= S0;
end
S6:
begin
state <= S0;
end
endcase
end
// Determine the output based only on the current state
// and the input (do not wait for a clock edge).
always @ (state or data_in)
begin
case (state)
S0:
if (data_in)
begin
data_out = 0;
end
else
begin
data_out = 1;
end
S1:
if (data_in)
begin
data_out = 0;
end
else
begin
data_out = 1;
end
S2:
if (data_in)
begin
data_out = 1;
end
else
begin
data_out = 0;
end
S3:
if (data_in)
begin
data_out = 1;
end
else
begin
data_out = 0;
end
S4:
if (data_in)
begin
data_out = 0;
end
else
begin
data_out = 1;
end
S5:
if (data_in)
begin
data_out = 1;
end
else
begin
data_out = 0;
end
S6:
begin
data_out = 1;
end
endcase
end
endmodule
_____________________________________________________
###1### testbench
`timescale 1ns / 1ps
module tb_bcd2ex3_1(
);
reg clk, data_in, reset;
wire data_out;;
reg[3:0] sequence;
integer i;
bcd2ex3_1 dut(clk, data_in, reset,data_out);
initial
begin
clk = 0;
reset = 1;
sequence = 4'b1001;
#5 reset = 0;
for( i = 0; i <= 3; i = i + 1)
begin
data_in= sequence[i];
#2 clk = 1;
#2 clk = 0;
$display("State = ", dut.state, " Input = ", data_in, ", Output = ", data_out);
end
end
endmodule
____________________________________________________________________________________________________
I need a screen of the results
Explanation / Answer
entity pulse is
port(clk_in : in std_logic;
clk_out : out std_logic;
data_in : in std_logic;
reset : in std_logic;
data_out : out std_logic_vector(15 downto 0));
end pulse;
type state_type is (s0, s1, s2, s3, s4, s5, s6);
signal state : state_type;
signal temporal : std_logic;
signal counter : integer range 0 to 757 := 0;
begin
frequency_divider: process (reset, clk_in) begin
if (reset = '1') then
temporal <= '0';
counter <= 0;
elsif rising_edge(clk_in) then
if (counter = 757) then
temporal <= NOT(temporal);
counter <= 0;
else
counter <= counter + 1;
end if;
end if;
end process;
process (temporal, reset)
begin
if reset = '1' then
state <= s0;
elsif (rising_edge(temporal)) then
case state is
when s0=>
if data_in = '1' then
state <= s1;
else
state <= s0;
end if;
when s1=>
if data_in = '1' then
state <= s2;
else
state <= s1;
end if;
when s2=>
if data_in = '1' then
state <= s3;
else
state <= s2;
end if;
when s3 =>
if data_in = '1' then
state <= s4;
else
state <= s3;
end if;
when s4 =>
if data_in = '1' then
state <= s5;
else
state <= s4;
end if;
when s5 =>
if data_in = '1' then
state <= s6;
else
state <= s5;
end if
end case;
end if;
end process;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.