Problems with my Code

OP #2130006
Rate this post
• ▲ useful
▼ not useful
Hey guys

I've been having problems with my code.

I'm trying to create a FSM with the following modules, each in a 
separate source file:

module ClockCounter(
    input clk,
    input rst,
    output clk_en
    );
reg [24:0] clk_count;

always @ (posedge clk, posedge rst)
begin
if (rst) clk_count <= 0;
  else clk_count <= clk_count+'b1;
end
assign clk_en = &clk_count;

endmodule


module OutputLogic(
    input [2:0] S,
    output reg LA, LB, LC, RA, RB, RC

    );

always @ ( * )
begin
LA <= ~S[0] & S[1] & S[2] | S[0] & S[1] & ~S[2] | S[0] & ~S[1] & S[2];
LB <= S[0] & S[1] & ~S[2] | S[0] & ~S[1] & S[2];
LC <= S[0] & ~S[1] & S[2];

RA <= ~S[0] & ~S[1] & S[2] | ~S[0] & S[1] & ~S[2] | S[0] & ~S[1] & 
~S[2];
RB <= ~S[0] & S[1] & ~S[2] | S[0] & ~S[1] & ~S[2];
RC <= S[0] & S[1] & ~S[2];
end

endmodule

module StateHoldingRegister(
    input [2:0] SN,
    input CLK,
    output reg [2:0] S
    );

always @ (posedge CLK)

S <= SN;



endmodule

module NextStateLogic(
    input [2:0] S,
    input L,
    input R,
    output reg [2:0] SN
    );

always @ ( * )

begin
SN [0] <= ~S[0] & S[1] | S[1] & ~S[2];
SN [1] <= S[0] & S[1] & S[2] & L & ~R | ~S[0] & S[2];
SN [2] <= ~S[0] & ~S[1] & ~S[2] & ~L & R | ~S[0] & ~S[1] & ~S[2] & L & 
~R | S[0] & S[1] & ~S[2];
end
endmodule


I have no idea how to connect them via verilog, so I created a schematic 
symbol for each and connected them via a new schematic source file.

However, I get this error:

ERROR:HDLCompilers:91 - "Thunderbird.vf" line 53 Module 
'NextStateLogic_MUSER_Thunderbird' does not have a port named 'L'
ERROR:HDLCompilers:91 - "Thunderbird.vf" line 54 Module 
'NextStateLogic_MUSER_Thunderbird' does not have a port named 'R'
ERROR:HDLCompilers:91 - "Thunderbird.vf" line 55 Module 
'NextStateLogic_MUSER_Thunderbird' does not have a port named 'S'
ERROR:HDLCompilers:91 - "Thunderbird.vf" line 56 Module 
'NextStateLogic_MUSER_Thunderbird' does not have a port named 'SN'

My question to you guys is, what's my mistake? How can I connect the 
modules through verilog?

Regards
Guest #2130064
Rate this post
• ▲ useful
▼ not useful
Id do not know about Verilog, but I found the actual problem:
> I have no idea how to connect them via verilog
Look how others are doing it. I expect the solution for your problem in 
the very first quarter of any Verilog book!
Guest #2130778
Rate this post
• ▲ useful
▼ not useful
http://www.verilog.renerta.com/source/vrg00027.htm

for example (but I have not done a syntax check)
[verilog]
module connect_them(
    input clk_from_xtal),
    input L_in,
    input R_in,
    output clk_en
    );

wire [2:0] SN_from_other_module;
wire [2:0] S_to_elsewhere);
wire [2:0] SN_to_othermodule;

 StateHoldingRegister  instance_name_1(
    .SN(SN_from_other_module,
   .clk(clk_from_xtal),
   .S(S_to_elsewhere)
    );

NextStateLogic instance_name_2(
    .S(S_to_elsewhere)),
    .L(L_in),
    .R(R_in),
    .SN(SN_to_othermodule)
    );

///.... an so on
[/verilog]

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.