data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new/KeyboardControl.v
1: b"%Error: data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new/KeyboardControl.v:52: Cannot find file containing module: 'InputNormalizer'\n  InputNormalizer inorm(\n  ^~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new,data/full_repos/permissive/42815087/InputNormalizer\n             data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new,data/full_repos/permissive/42815087/InputNormalizer.v\n             data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new,data/full_repos/permissive/42815087/InputNormalizer.sv\n             InputNormalizer\n             InputNormalizer.v\n             InputNormalizer.sv\n             obj_dir/InputNormalizer\n             obj_dir/InputNormalizer.v\n             obj_dir/InputNormalizer.sv\n%Error: data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new/KeyboardControl.v:74: Cannot find file containing module: 'ClockDivider'\n  ClockDivider mcdiv(\n  ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new/KeyboardControl.v:81: Cannot find file containing module: 'ClockDivider'\n  ClockDivider ccdiv(\n  ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/42815087/cpu/SyzygyB100.srcs/sources_1/new/KeyboardControl.v:88: Cannot find file containing module: 'KeyboardInterface'\n  KeyboardInterface kbdIntr(\n  ^~~~~~~~~~~~~~~~~\n%Error: Exiting due to 4 error(s)\n"
module KeyboardControl(
    input clk,
    input [15:0] sw,
    input btnL,
    input btnU,
    input btnC,
    input btnD,
    input btnR,
    input PS2Clk,
    input PS2Data,
    inout [3:0] JB,
    output [15:0] led,
    output [6:0] seg,
    output [3:0] an,
    output dp  
  );
  
  reg [3:0] regNum;
  reg [15:0] regData;
  reg intrRdEn;
  reg intrWrEn;
  
  wire [15:0] wSwitchesOut;
  wire buttonLeft;
  wire buttonUp;
  wire buttonCenter;
  wire buttonDown;
  wire buttonRight;
  wire wDPIn;
  InputNormalizer inorm(
    .clk(clk),
    .switchIn(sw[15:0]),
    .btnLIn(btnL),
    .btnUIn(btnU),
    .btnCIn(btnC),
    .btnDIn(btnD),
    .btnRIn(btnR),
    .segsIn(regData[15:0]),
    .dpIn(~wDPIn),
    .switchOut(wSwitchesOut[15:0]),
    .btnLOut(buttonLeft),
    .btnUOut(buttonUp),
    .btnCOut(buttonCenter),
    .btnDOut(buttonDown),
    .btnROut(buttonRight),
    .segsOut(seg[6:0]),
    .anOut(an[3:0]),
    .dpOut(dp)
  );
  
  wire wMemClk;
  ClockDivider mcdiv(
    .cIn(clk),
    .reqCount(3),
    .cOut(wMemClk)
  );
  
  wire wCPUClk;
  ClockDivider ccdiv(
    .cIn(wMemClk),
    .reqCount(2),
    .cOut(wCPUClk)
  );
  
  wire [15:0] wKeycodeOut;
  KeyboardInterface kbdIntr(
    .ctrlClock(clk),
    .cpuClock(wCPUClk),
    .periphSelect(1'b1),
    .dIn(16'h0000),
    .regSelect(regNum[3:0]),
    .readEn(intrRdEn),
    .writeEn(intrWrEn),
    .reset(1'b0),
    .exec(buttonCenter),
    .debugRegSelect(4'h0),
    .ps2Clk(PS2Clk),
    .ps2Dat(PS2Data),
    .dOut(wKeycodeOut[15:0]),
    .debugOut()
  );
  
  always @ (posedge clk) begin
    if(buttonUp == 1'b1) begin
      regNum[3:0] = wSwitchesOut[3:0];
    end
    
    if(buttonDown == 1'b1) begin
      regData[15:0] = wSwitchesOut[15:0];
    end
    
    if(buttonLeft == 1'b1) begin
      intrRdEn = 1'b1;
      regData[15:0] = wKeycodeOut[15:0];
    end else begin
      intrRdEn = 1'b0;
    end
    
    if(buttonRight == 1'b1) begin
      intrWrEn = 1'b1;
    end else begin
      intrWrEn = 1'b0;
    end
  end
  
endmodule
module KeyboardControl(
    input clk,
    input [15:0] sw,
    input btnL,
    input btnU,
    input btnC,
    input btnD,
    input btnR,
    input PS2Clk,
    input PS2Data,
    inout [3:0] JB,
    output [15:0] led,
    output [6:0] seg,
    output [3:0] an,
    output dp  
  );

  
  reg [3:0] regNum;
  reg [15:0] regData;
  reg intrRdEn;
  reg intrWrEn;
  
  wire [15:0] wSwitchesOut;
  wire buttonLeft;
  wire buttonUp;
  wire buttonCenter;
  wire buttonDown;
  wire buttonRight;
  wire wDPIn;
  InputNormalizer inorm(
    .clk(clk),
    .switchIn(sw[15:0]),
    .btnLIn(btnL),
    .btnUIn(btnU),
    .btnCIn(btnC),
    .btnDIn(btnD),
    .btnRIn(btnR),
    .segsIn(regData[15:0]),
    .dpIn(~wDPIn),
    .switchOut(wSwitchesOut[15:0]),
    .btnLOut(buttonLeft),
    .btnUOut(buttonUp),
    .btnCOut(buttonCenter),
    .btnDOut(buttonDown),
    .btnROut(buttonRight),
    .segsOut(seg[6:0]),
    .anOut(an[3:0]),
    .dpOut(dp)
  );
  
  wire wMemClk;
  ClockDivider mcdiv(
    .cIn(clk),
    .reqCount(3),
    .cOut(wMemClk)
  );
  
  wire wCPUClk;
  ClockDivider ccdiv(
    .cIn(wMemClk),
    .reqCount(2),
    .cOut(wCPUClk)
  );
  
  wire [15:0] wKeycodeOut;
  KeyboardInterface kbdIntr(
    .ctrlClock(clk),
    .cpuClock(wCPUClk),
    .periphSelect(1'b1),
    .dIn(16'h0000),
    .regSelect(regNum[3:0]),
    .readEn(intrRdEn),
    .writeEn(intrWrEn),
    .reset(1'b0),
    .exec(buttonCenter),
    .debugRegSelect(4'h0),
    .ps2Clk(PS2Clk),
    .ps2Dat(PS2Data),
    .dOut(wKeycodeOut[15:0]),
    .debugOut()
  );
  
  always @ (posedge clk) begin
    if(buttonUp == 1'b1) begin
      regNum[3:0] = wSwitchesOut[3:0];
    end
    
    if(buttonDown == 1'b1) begin
      regData[15:0] = wSwitchesOut[15:0];
    end
    
    if(buttonLeft == 1'b1) begin
      intrRdEn = 1'b1;
      regData[15:0] = wKeycodeOut[15:0];
    end else begin
      intrRdEn = 1'b0;
    end
    
    if(buttonRight == 1'b1) begin
      intrWrEn = 1'b1;
    end else begin
      intrWrEn = 1'b0;
    end
  end
  
endmodule