Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 102 lines (76 sloc) 2.042 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
`timescale 1 ns / 10 ps

`define PERIOD 10
`define HALF_PERIOD 5

`include "keycodes.vh"

module test_al_controller;

    reg MCLK=0;
    reg t_reset=1;
    reg t_one_second=0;

    /* This is the test clock */
    always
    begin
        #`HALF_PERIOD MCLK = ~MCLK;
    end
    
    /*
* 256 Hz
*/
    wire t_clk256;

    localparam clock_div = 1; /* counts 0,1,0,1,0,1,0,1,... */
    FREQ_DIV #(clock_div) run_freq_div
        (.clk(MCLK),
         .reset(t_reset),
         .clk256(t_clk256) );

    /*
* Keyboard
*/

    wire ps2c;
    wire ps2d;

    wire [7:0] t_key_in;
    wire [15:0] int_key_buffer;

    wire wire_set_alarm;
    wire wire_set_time;

    kbd_if run_kbd_if
        ( .clk(MCLK),
          .reset(t_reset),

          .PS2C(ps2c),
          .PS2D(ps2d),

          /* outputs */
          .key(t_key_in)
        );

    /*
* AL Controller
*/
    wire t_load_alarm;
    wire t_show_alarm;
    wire t_load_new_time;
    wire t_show_keyboard;

    AL_Controller run_al_clk_counter
        ( .clk(MCLK),
          .reset(t_reset),
          .one_second(t_one_second),
          .key(t_key_in),
// .set_alarm(0), // on the spec but not used; a key (*) used for set alarm
// .set_time(0), // on the spec but not used; a key (-) used for set time
          
          /* outputs */
          .out_key_buffer(int_key_buffer),
          .load_alarm(t_load_alarm),
          .show_alarm(t_show_alarm),
          .load_new_time(t_load_new_time),
          .out_show_keyboard(t_show_keyboard)
       );

    initial
    begin

        $display("Hello, world");
        $dumpfile("test_al_controller.vcd");
        $dumpvars(0,test_al_controller);

        $monitor( "%d load_alarm=%d show_alarm=%d load_new_time=%d disp=%x",
                $time, t_load_alarm, t_show_alarm, t_load_new_time,
                int_key_buffer );

        # `PERIOD;
        @(negedge MCLK);
        t_reset = ~t_reset;
        # `PERIOD;

        # 4000;
        $finish;
    end

endmodule


Something went wrong with that request. Please try again.