kexp.v 2.02 KB
// This confidential and propriety software may be used
// only as authorized by a licensing agreement from
// Ocean Logic Pty Ltd http://www.ocean-logic.com
// 
// In the event of publication, the following notice is
// applicable
// 
// (C) COPYRIGHT 2001 Ocean Logic Pty Ltd
// ALL RIGHTS RESERVED
//
// the entire notice must be reproduced on all
// authorized copies
// 
// File : aes.vhd
// Author : Vincenzo Liguori
// Date : 01-03-02
// Version 1.0
// Abstract :
// This implements the key expander top module
// 
// Modification history :
// Date      by  Version  Change description
// -------------------------------------------------
// 01-03-02  VL   1.0     Original

module kexp(
clk,
rstn,
go,
en,
ksize,
kin,
key,
addr,
first,
final,
key_req,
key_last
);

// Inputs
input clk, rstn;
input go, en;
input[1:0] ksize;
input[31:0] kin;
// Outputs 
output[31:0] key;
output[5:0] addr;
output first, final, key_req, key_last;

wire   clk;
wire   rstn;
wire   go;
wire   en;
wire  [1:0] ksize;
wire  [31:0] kin;
wire  [31:0] key;
wire  [5:0] addr;
wire   first;
wire   final;
wire   key_req;
wire   key_last;


wire [4:0] rcaddr;
wire  rotsel;
wire  sel;
wire  kinit;
wire [2:0] kaddr;
wire [31:0] oldkey;

  ctrl ct(
      // Inputs
    .clk(clk),
    .rstn(rstn),
    .en(en),
    .go(go),
    .ksize(ksize),
    // Outputs 
    .rotsel(rotsel),
    .sel(sel),
    .kinit(kinit),
    .kaddr(kaddr),
    .rcaddr(rcaddr),
    .addr(addr),
    .first(first),
    .final(final),
    .key_last(key_last));

  assign key_req = kinit;
  // Key storage area
  mem8 km(
      .clk(clk),
    .rstn(rstn),
    .en(en),
    .we(go),
    .ar(kaddr),
    .aw(kaddr),
    .din(key),
    .dout(oldkey));

  // Key scheduler/expander
  keysched ks(
      .clk(clk),
    .rstn(rstn),
    .en(en),
    .rotsel(rotsel),
    .sel(sel),
    .kinit(kinit),
    .kin(kin),
    .oldkey(oldkey),
    .rcaddr(rcaddr),
    // Outputs 
    .key(key));


endmodule