PATH: //opt/alt/python311/share/doc/alt-python311-pyparsing-doc/examples/verilog
FILE_BARU
CREATE
FOLDER_BARU
MKDIR
UPLOAD_FILE
GO
[ .. KEMBALI ]
📄 Ctr3sr.v
↓
X
📄 INIT
↓
X
📄 RANDOM_GATE
↓
X
📄 RANDOM_INTERCONNECT
↓
X
📄 SEED
↓
X
📄 TestCtr3sr.v
↓
X
📄 addacc.v
↓
X
📄 addacc1_dro.v
↓
X
📄 addacc1_t1ff.v
↓
X
📄 addacc_conf.v
↓
X
📄 addacc_dro.v
↓
X
📄 addacc_t1ff.v
↓
X
📄 allParseOutput.zip
↓
X
📄 and.v
↓
X
📄 and_gate.v
↓
X
📄 conf.v
↓
X
📄 core_test.v
↓
X
📄 count2bit.v
↓
X
📄 count_all_prims_test.v
↓
X
📄 count_loads_test.v
↓
X
📄 dds.v
↓
X
📄 diff_udp.v
↓
X
📄 display_all_nets_test.v
↓
X
📄 div16.v
↓
X
📄 dro.v
↓
X
📄 dro1_cell.v
↓
X
📄 dro_cell.v
↓
X
📄 dump_and_fill_mem_test.v
↓
X
📄 exprinfo_test.v
↓
X
📄 fetch_values_test.v
↓
X
📄 ff.v
↓
X
📄 ff_test.v
↓
X
📄 fifo.v
↓
X
📄 find_driver.tcl.gz
↓
X
📄 framer.v
↓
X
📄 func_72bit_test.v
↓
X
📄 gen.v
↓
X
📄 gencrc.v
↓
X
📄 gzip.exe
↓
X
📄 hadd.v
↓
X
📁 hasCompilerDirectives/
X
📄 hello_test.v
↓
X
📄 in_port.v
↓
X
📄 inv.v
↓
X
📄 inv_cell.v
↓
X
📄 invoke_commands_test.v
↓
X
📄 invoke_options_test.v
↓
X
📄 jtl2.v
↓
X
📄 jutzi
↓
X
📄 list_cells_test.v
↓
X
📄 list_nets_test.v
↓
X
📄 list_parameters_test.v
↓
X
📄 list_path_delays_test.v
↓
X
📄 list_pathout_ports_test.v
↓
X
📄 list_prim_delays_test.v
↓
X
📄 load_in.v
↓
X
📄 load_out.v
↓
X
📄 mem_arb.v
↓
X
📄 mipd_delays_test.v
↓
X
📄 mult16.v
↓
X
📄 multi21_udp.v
↓
X
📄 my_monitor1_test.v
↓
X
📄 my_monitor2_test.v
↓
X
📄 my_monitor_test.v
↓
X
📄 my_strobe_test.v
↓
X
📄 myram64x16.v
↓
X
📄 nco.v
↓
X
📄 ndro.v
↓
X
📁 new/
X
📁 new2/
X
📁 new3/
X
📄 nodeinfo_test.v
↓
X
📄 onehot.v
↓
X
📄 or.v
↓
X
📄 out_port.v
↓
X
📁 parseOutput/
X
📄 pic.v
↓
X
📄 pipe1.v
↓
X
📄 pipe2.v
↓
X
📄 pl.v
↓
X
📄 pli_handbook_examples_pc.zip
↓
X
📄 port_info_test.v
↓
X
📄 pow_test.v
↓
X
📄 primitives.v
↓
X
📄 propagatep_test.v
↓
X
📄 psr1.v
↓
X
📄 psr1_conf.v
↓
X
📄 psr1_dro.v
↓
X
📄 psr1_split.v
↓
X
📄 psr2.v
↓
X
📄 psr2_and.v
↓
X
📄 psr2_split.v
↓
X
📄 read_4state_value_test.v
↓
X
📄 read_attribute_test.v
↓
X
📄 read_delays_test.v
↓
X
📄 read_stimulus_short_test.v
↓
X
📄 read_stimulus_test.v
↓
X
📄 read_strengthval_test.v
↓
X
📄 read_test_vector_test.v
↓
X
📄 read_timeval_test.v
↓
X
📄 read_vector_test.v
↓
X
📄 read_vecval_test.v
↓
X
📄 realpow_test.v
↓
X
📄 rf.v
↓
X
📄 sci_alu_comb_calltf_shell.v
↓
X
📄 sci_alu_comb_calltf_test.v
↓
X
📄 sci_alu_comb_misctf_shell.v
↓
X
📄 sci_alu_comb_misctf_test.v
↓
X
📄 sci_alu_combinational_shell.v
↓
X
📄 sci_alu_combinational_test.v
↓
X
📄 sci_alu_latched_shell.v
↓
X
📄 sci_alu_latched_test.v
↓
X
📄 sci_alu_sequential_shell.v
↓
X
📄 sci_alu_sequential_test.v
↓
X
📄 sci_alu_synchronized_shell.v
↓
X
📄 sci_alu_synchronized_test.v
↓
X
📄 sci_alu_with_delays_shell.v
↓
X
📄 sci_alu_with_delays_test.v
↓
X
📄 set_mipd_delays_test.v
↓
X
📄 show_all_nets_test.v
↓
X
📄 show_all_signals1_test.v
↓
X
📄 show_all_signals2_test.v
↓
X
📄 show_all_signals3_test.v
↓
X
📄 show_all_signals_1_test.v
↓
X
📄 show_all_signals_2_test.v
↓
X
📄 show_all_signals_3_test.v
↓
X
📄 show_value_test.v
↓
X
📄 sig_gen.v
↓
X
📄 simple_core.v
↓
X
📄 splitter.v
↓
X
📄 sqrt32.v
↓
X
📄 sqrt8m.v
↓
X
📄 sr_nv_ctf.v
↓
X
📄 srcnt.v
↓
X
📄 string.v
↓
X
📄 t1ff.v
↓
X
📄 testcase.v
↓
X
📄 testcase2.v
↓
X
📄 testcase3.v
↓
X
📄 testcase4.v
↓
X
📄 testcase5.v
↓
X
📄 tff.v
↓
X
📄 timescale_info_test.v
↓
X
📄 usb.v
↓
X
📄 use_workarea_test.v
↓
X
📄 utmi_if.v
↓
X
📄 vpi_utilities_test.v
↓
X
📄 wb.v
↓
X
📄 wpulse.v
↓
X
📄 xor.v
↓
X
📄 zzzexample.v
↓
X
SAVING...
BERHASIL DIUBAH!
EDITING: onehot.v
// // Just a little demo of some FSM techniques, including One-Hot and // using 'default' settings and the case statements to selectively // update registers (sort of like J-K flip-flops). // // tom coonan, 12/98. // module onehot (clk, resetb, a, b, x, y); input clk; input resetb; input [7:0] a; input [7:0] b; output [7:0] x; output [7:0] y; // Use One-Hot encoding. There will be 16 states. // reg [15:0] state, next_state; // These are working registers. Declare the register itself (e.g. 'x') and then // the input bus used to load in a new value (e.g. 'x_in'). The 'x_in' bus will // physically be a wire bus and 'x' will be the flip-flop register ('x_in' must // be declared 'reg' because it's used in an always block. // reg [7:0] x, x_in; reg [7:0] y, y_in; // Update state. 'state' is the actual flip-flop register and next_state is the combinatorial // bus used to update 'state''s value. Check for the ZERO state which means an unexpected // next state was computed. If this occurs, jump to our initialization state; state[0]. // // It is considered good practice by many designers to seperate the combinatorial // and sequential aspects of state registers, and often registers in general. // always @(posedge clk or negedge resetb) begin if (~resetb) state <= 0; else begin if (next_state == 0) begin state <= 16'h0001; end else begin state <= next_state; end end end // Implement the X flip-flop register. Always load the input bus into the register. // Reset to zero. // always @(posedge clk or negedge resetb) begin if (~resetb) x <= 0; else x <= x_in; end // Implement the Y flip-flop register. Always load the input bus into the register. // Reset to zero. // always @(posedge clk or negedge resetb) begin if (~resetb) y <= 0; else y <= y_in; end // Generate the next_state function. Also, based on the current state, generate // any new values for X and Y. // always @(state or a or b or x or y) begin // *** Establish defaults. // Working registers by default retain their current value. If any particular // state does NOT need to change a register, then it doesn't have to reference // the register at all. In these cases, the default below takes affect. This // turns out to be a pretty succinct way to control stuff from the FSM. // x_in <= x; y_in <= y; // State by default will be cleared. If we somehow ever got into an unknown // state, then the default would throw state machine back to zero. Look // at the sequential 'always' block for state to see how this is handled. // next_state <= 0; // One-Hot State Machine Encoding. // // *** Using a 1'b1 in the case statement is the trick to doing One-Hot... // DON'T include a 'default' clause within the case because we want to // establish the defaults above. *** // case (1'b1) // synopsys parallel_case // Initialization state. Set X and Y register to some interesting starting values. // state[0]: begin x_in <= 8'd20; y_in <= 8'd100; next_state[1] <= 1'b1; end // Just for fun.. Jump through states.. state[1]: next_state[2] <= 1'b1; state[2]: next_state[3] <= 1'b1; state[3]: next_state[4] <= 1'b1; state[4]: next_state[5] <= 1'b1; state[5]: next_state[6] <= 1'b1; state[6]: next_state[7] <= 1'b1; // Conditionally decrement Y register. state[7]: begin if (a == 1) begin y_in <= y - 1; next_state[1] <= 1'b1; end else begin next_state[8] <= 1'b1; end end // Just for fun.. Jump through states.. state[8]: next_state[9] <= 1'b1; state[9]: next_state[10] <= 1'b1; state[10]: next_state[11] <= 1'b1; // Conditionally increment X register. state[11]: begin if (b == 1) begin x_in <= x + 1; next_state[1] <= 1'b1; end else begin next_state[12] <= 1'b1; end end // Just for fun.. Jump through states.. state[12]: next_state[13] <= 1'b1; state[13]: next_state[14] <= 1'b1; state[14]: next_state[15] <= 1'b1; state[15]: next_state[1] <= 1'b1; // Don't go back to our initialization state, but state following that one. endcase end endmodule // synopsys translate_off module test_onehot; reg clk, resetb; reg [7:0] a; reg [7:0] b; wire [7:0] x; wire [7:0] y; // Instantiate module. // onehot onehot ( .clk(clk), .resetb(resetb), .a(a), .b(b), .x(x), .y(y) ); // Generate clock. // initial begin clk = 0; forever begin #10 clk = ~clk; end end // Reset.. // initial begin resetb = 0; #33 resetb = 1; end // Here's the test. // // Should see X and Y get initially loaded with their starting values. // As long as a and b are zero, nothing should change. // When a is asserted, Y should slowly decrement. When b is asserted, X should // slowly increment. That's it. // initial begin a = 0; b = 0; repeat (64) @(posedge clk); #1 // Y should be decremented.. a = 1; b = 0; repeat (256) @(posedge clk); #1 // X should be incremented.. a = 0; b = 1; repeat (256) @(posedge clk); $finish; end // Monitor the module. // initial begin forever begin @(posedge clk); #1; $display ("a = %b, b = %b, x = %0d, y = %0d", a,b,x,y); end end endmodule
SIMPAN PERUBAHAN