FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-26-2003, 07:15 AM
Bose
Guest
 
Posts: n/a
Default Verilog Program With A Problem

Hi to all,

I'm writing a program using verilog at the moment. The program that
i'm doing now is one of many blocks that will be finally linked up
together...Right now, i'm having some problems with my program...In my
program, i have a part where i need to compare the input(eingated) &
an output(eout_prev) of another program which is a D flip flop. So in
my program what should i define "eout_prev" as? An input, output, reg
....?
I need help urgently. Anyone can help me out ?

Thanks a lot! :-)

Below is my program & the D flip flop program ,and i have pointed to
where my problem lies.


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

`timescale 1ns/1ps

module encoder(eingated, clr, clk, keydet, inhibit, eout);

input [3:0]eingated;
input clr, clk;
output keydet, inhibit;
output [3:0]eout;
reg [3:0]eout;
reg keydet, inhibit;

parameter idle = 1'b0, keypressed = 1'b1;
reg [1:0] cur_state, next_state;
reg eout_prev;


always @(posedge clk or negedge clr)
begin
if(clr==0)
cur_state = idle;
else
cur_state = next_state;
end



always@(cur_state or eingated or eout or eout_prev)
begin
case(cur_state)
idle : if (eingated == 4'b1110 || eingated == 4'b1101 ||
eingated == 4'b1011 || eingated == 4'b0111)
begin
keydet = 1'b1;
inhibit = 1'b1;
next_state = keypressed;
end
else
begin
keydet = 1'b0;
inhibit = 1'b0;
next_state = idle;
end


keypressed : if (eingated == 4'b1110 || eingated == 4'b1101 ||
eingated == 4'b1011 || eingated == 4'b0111)
if (eout == eout_prev) <------- What to define
begin "eout_prev" as?
keydet = 1'b1;
inhibit = 1'b1;
next_state = keypressed;
end
else
begin
keydet = 1'b0;
inhibit = 1'b1;
next_state = idle;
end
else
begin
keydet = 1'b0;
inhibit = 1'b0;
next_state = idle;
end
endcase
end


always @(eingated)
begin
case (eingated)
4'b1110: eout = 2'b00;
4'b1101: eout = 2'b01;
4'b1011: eout = 2'b10;
4'b0111: eout = 2'b11;
default: eout = 2'b0;
endcase
end

endmodule


--------------------------------------------------------------------------------
Below is the program of the D flip flop with output "eout_prev" :



`timescale 1ns/1ps

module eoutTemp(eout, keydet, clear, eout_prev);

input [1:0] eout;
input keydet, clear;

output [1:0] eout_prev;
reg [1:0] eout_prev;

always @(posedge keydet or negedge clear)
if(clear==0)
eout_prev<=2'b0;
else eout_prev<={eout};

endmodule
Reply With Quote
  #2 (permalink)  
Old 10-26-2003, 09:54 AM
Peng Cong
Guest
 
Posts: n/a
Default Re: Verilog Program With A Problem

In module encoder, "eout_prev" is an input

"Bose" <[email protected]> 写入消息新闻
:[email protected].. .
> Hi to all,
>
> I'm writing a program using verilog at the moment. The program that
> i'm doing now is one of many blocks that will be finally linked up
> together...Right now, i'm having some problems with my program...In my
> program, i have a part where i need to compare the input(eingated) &
> an output(eout_prev) of another program which is a D flip flop. So in
> my program what should i define "eout_prev" as? An input, output, reg
> ...?
> I need help urgently. Anyone can help me out ?
>
> Thanks a lot! :-)
>
> Below is my program & the D flip flop program ,and i have pointed to
> where my problem lies.
>
>
> --------------------------------------------------------------------------

------
>
> `timescale 1ns/1ps
>
> module encoder(eingated, clr, clk, keydet, inhibit, eout);
>
> input [3:0]eingated;
> input clr, clk;
> output keydet, inhibit;
> output [3:0]eout;
> reg [3:0]eout;
> reg keydet, inhibit;
>
> parameter idle = 1'b0, keypressed = 1'b1;
> reg [1:0] cur_state, next_state;
> reg eout_prev;
>
>
> always @(posedge clk or negedge clr)
> begin
> if(clr==0)
> cur_state = idle;
> else
> cur_state = next_state;
> end
>
>
>
> always@(cur_state or eingated or eout or eout_prev)
> begin
> case(cur_state)
> idle : if (eingated == 4'b1110 || eingated == 4'b1101 ||
> eingated == 4'b1011 || eingated == 4'b0111)
> begin
> keydet = 1'b1;
> inhibit = 1'b1;
> next_state = keypressed;
> end
> else
> begin
> keydet = 1'b0;
> inhibit = 1'b0;
> next_state = idle;
> end
>
>
> keypressed : if (eingated == 4'b1110 || eingated == 4'b1101 ||
> eingated == 4'b1011 || eingated == 4'b0111)
> if (eout == eout_prev) <------- What to define
> begin "eout_prev" as?
> keydet = 1'b1;
> inhibit = 1'b1;
> next_state = keypressed;
> end
> else
> begin
> keydet = 1'b0;
> inhibit = 1'b1;
> next_state = idle;
> end
> else
> begin
> keydet = 1'b0;
> inhibit = 1'b0;
> next_state = idle;
> end
> endcase
> end
>
>
> always @(eingated)
> begin
> case (eingated)
> 4'b1110: eout = 2'b00;
> 4'b1101: eout = 2'b01;
> 4'b1011: eout = 2'b10;
> 4'b0111: eout = 2'b11;
> default: eout = 2'b0;
> endcase
> end
>
> endmodule
>
>
> --------------------------------------------------------------------------

------
> Below is the program of the D flip flop with output "eout_prev" :
>
>
>
> `timescale 1ns/1ps
>
> module eoutTemp(eout, keydet, clear, eout_prev);
>
> input [1:0] eout;
> input keydet, clear;
>
> output [1:0] eout_prev;
> reg [1:0] eout_prev;
>
> always @(posedge keydet or negedge clear)
> if(clear==0)
> eout_prev<=2'b0;
> else eout_prev<={eout};
>
> endmodule



Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
verilog HDL problem babu Verilog 3 06-09-2007 02:37 PM
NC-Verilog hdl.var problem? Davy Verilog 1 02-12-2006 12:33 PM
verilog problem Debbie Unger Verilog 0 08-27-2004 09:31 AM
my first Verilog program Frank Buss Verilog 4 08-07-2004 06:56 PM


All times are GMT +1. The time now is 12:44 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved