Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

what is wrong with my code????????

Status
Not open for further replies.

f2t1

Newbie level 4
Joined
Mar 15, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
indonesia
Activity points
1,322
i am newbie in verilog and just dont know what is wrong with my code.
this is the crazy simple question:

Develop a Verilog model for a thermostat that has two 8-bit unsigned binary inputs representing the target temperature and the actual temperature in degrees Fahrenheit (˚F). Assume that both temperatures are above freezing (32˚F). The detector has two outputs: one to turn a heater on when the actual temperature is more than 5˚F below target, and one to turn a cooler onwhen the actual temperature is more than 5˚F above target.

and this is my code:

module*C2*(switch,clk,heater_on,cooler_on,enable_a ctual,enable_target);


input clk;
input enable_actual,enable_target;
input*[7:0]*switch*;
reg [7:0]*actual,target;
output* heater_on,*cooler_on;

always @(posedge clk)
begin
if (enable_actual) actual <= switch;

else if (enable_target) target <= switch;

end

assign*heater_on*=*actual*<*target*-*5;
assign*cooler_on*=*actual*>*target*+*5;

endmodule

it didnt show error during compilation.the problem is that the output which are heater_on and cooler_on didnt turn on correctly.what is wrong with my code??can somebody pls help me.

picture2 is the simulation when i want the output heater on to be on.
picture4 is the simulation when i want the output cooler on to be on.

but the simulation was not what i expected for:help pls
 

Attachments

  • Picture2.jpg
    Picture2.jpg
    131.1 KB · Views: 79
  • Picture4.jpg
    Picture4.jpg
    133.3 KB · Views: 82

The code is O.K., but the simulation stimulus isn't reasonable. You don't manage to set actual and target as intended.
 

The switch input must be hold while enable_actual respectively enable_target are active.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top