Advertisement
Krystian102

Untitled

Apr 9th, 2020
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module zad5(
  2.     input CLOCK_50,
  3.     input [2:0] SW,
  4.     input [1:0] KEY,
  5.     output [0:0] LEDR);
  6.    
  7.     wire clk;
  8.     integer iterator = 0;
  9.     wire [0:12] symbolStruct;
  10.    
  11.     counter_to_make_delay_0_5sek(CLOCK_50,1,clk);
  12.     morse_symbols(SW,symbolStruct);
  13.    
  14.     reg dioda;
  15.     reg [0:12] symbol;
  16.     assign LEDR[0] = dioda;
  17.    
  18.     always@(posedge clk, negedge KEY[0])
  19.         begin
  20.             if(~KEY[0])
  21.                 begin
  22.                     dioda<=0;
  23.                     iterator=0;
  24.                 end
  25.             else if(KEY[1])
  26.                 begin
  27.                     dioda<=symbolStruct[iterator];
  28.                     iterator=iterator+1;
  29.                 end
  30.         end
  31. endmodule
  32.  
  33. module counter_to_make_delay_0_5sek(
  34.     input clk, aclr,
  35.     output reg clockTact);
  36.    
  37.     reg [25:0] i;
  38.    
  39.     always@(posedge clk, negedge aclr)
  40.         if(!aclr)
  41.             begin
  42.                 i<=0;
  43.                 clockTact<=0;
  44.             end
  45.         else
  46.             begin
  47.                 if(i==2)
  48.                     begin
  49.                         i<=0;
  50.                         clockTact<=1;
  51.                     end
  52.                 else
  53.                     begin
  54.                         i<=i+1;
  55.                         clockTact<=0;
  56.                     end
  57.             end
  58.    
  59. endmodule
  60.  
  61. module morse_symbols(
  62.     input [2:0] in,
  63.     output reg [0:12] out);
  64.    
  65.     always@(*)
  66.         case(in)
  67.             3'b000: out=13'b0101110000000;
  68.             3'b001: out=13'b0111010101000;
  69.             3'b010: out=13'b0111010111010;
  70.             3'b011: out=13'b0111010100000;
  71.             3'b100: out=13'b0100000000000;
  72.             3'b101: out=13'b0101011101000;
  73.             3'b110: out=13'b1110111010000;
  74.             3'b111: out=13'b0101010100000;
  75.         endcase
  76.    
  77. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement