OpenCores
URL https://opencores.org/ocsvn/ssbcc/ssbcc/trunk

Subversion Repositories ssbcc

[/] [ssbcc/] [trunk/] [core/] [9x8/] [core.v] - Diff between revs 2 and 7

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 7
Line 1... Line 1...
/*******************************************************************************
/*******************************************************************************
 *
 *
 * Copyright 2012-2013, Sinclair R.F., Inc.
 * Copyright 2012-2014, Sinclair R.F., Inc.
 *
 *
 * SSBCC.9x8 -- Small Stack Based Computer Compiler, 9-bit opcode, 8-bit data.
 * SSBCC.9x8 -- Small Stack Based Computer Compiler, 9-bit opcode, 8-bit data.
 *
 *
 * The repository for this open-source project is at
 * The repository for this open-source project is at
 *   https://github.com/sinclairrf/SSBCC
 *   https://github.com/sinclairrf/SSBCC
Line 37... Line 37...
 
 
//@SSBCC@ signals
//@SSBCC@ signals
 
 
/*******************************************************************************
/*******************************************************************************
 *
 *
 * Instantiate the ALU operations.  These are listed in the order in which they
 * Instantiate the ALU operations.  These are listed in order by opcode.
 * first occur in the opcodes.
 
 *
 *
 ******************************************************************************/
 ******************************************************************************/
 
 
 
reg [8:0] s_T_adder;
 
 
// opcode = 000000_xxx
// opcode = 000000_xxx
// shifter operations (including "nop" as no shift)
// shifter operations (including "nop" as no shift)
// 6-input LUT formulation -- 3-bit opcode, 3 bits of T centered at current bit
// 6-input LUT formulation -- 3-bit opcode, 3 bits of T centered at current bit
reg [7:0] s_math_rotate;
reg [7:0] s_math_rotate;
always @ (s_T,s_opcode)
always @ (s_T,s_opcode)
Line 67... Line 68...
always @ (*)
always @ (*)
  case (s_opcode[0+:2])
  case (s_opcode[0+:2])
      2'b00 : s_T_stack = s_T;                  // dup
      2'b00 : s_T_stack = s_T;                  // dup
      2'b01 : s_T_stack = s_R[0+:8];            // r@
      2'b01 : s_T_stack = s_R[0+:8];            // r@
      2'b10 : s_T_stack = s_N;                  // over
      2'b10 : s_T_stack = s_N;                  // over
 
      2'b11 : s_T_stack = { 7'd0, s_T_adder[8] };       // +/-c
    default : s_T_stack = s_T;
    default : s_T_stack = s_T;
  endcase
  endcase
 
 
//  opcode = 000011_x00 (adder) and 001xxx_x.. (incrementers)
//  opcode = 000011_x00 (adder) and 001xxx_x.. (incrementers)
reg [7:0] s_T_adder;
 
always @ (*)
always @ (*)
  if (s_opcode[6] == 1'b0)
  if (s_opcode[6] == 1'b0)
    case (s_opcode[2])
    case (s_opcode[2])
       1'b0: s_T_adder = s_N + s_T;
       1'b0: s_T_adder = { 1'b0, s_N } + { 1'b0, s_T };
       1'b1: s_T_adder = s_N - s_T;
       1'b1: s_T_adder = { 1'b0, s_N } - { 1'b0, s_T };
    endcase
    endcase
  else
  else begin
    case (s_opcode[2])
    case (s_opcode[2])
       1'b0: s_T_adder = s_T + 8'h01;
       1'b0: s_T_adder = { 1'b0, s_T } + 9'h01;
       1'b1: s_T_adder = s_T - 8'h01;
       1'b1: s_T_adder = { 1'b0, s_T } - 9'h01;
    default: s_T_adder = s_T + 8'h01;
    default: s_T_adder = { 1'b0, s_T } + 9'h01;
    endcase
    endcase
 
  end
 
 
// opcode = 000100_0xx
// opcode = 000100_0xx
//                   ^ 0 ==> "=", 1 ==> "<>"
//                   ^ 0 ==> "=", 1 ==> "<>"
//                  ^  0 ==> all zero, 1 ==> all ones
//                  ^  0 ==> all zero, 1 ==> all ones
wire s_T_compare = s_opcode[0] ^ &(s_T == {(8){s_opcode[1]}});
wire s_T_compare = s_opcode[0] ^ &(s_T == {(8){s_opcode[1]}});
Line 216... Line 218...
    s_bus_n     = C_BUS_N_STACK;
    s_bus_n     = C_BUS_N_STACK;
    s_stack     = C_STACK_DEC;
    s_stack     = C_STACK_DEC;
  end else case (s_opcode[3+:4])
  end else case (s_opcode[3+:4])
      4'b0000:  // nop, math_rotate
      4'b0000:  // nop, math_rotate
                ;
                ;
      4'b0001:  begin // dup, r@, over
      4'b0001:  begin // dup, r@, over, +/-c
                s_bus_t         = C_BUS_T_PRE;
                s_bus_t         = C_BUS_T_PRE;
                s_bus_n         = C_BUS_N_T;
                s_bus_n         = C_BUS_N_T;
                s_stack         = C_STACK_INC;
                s_stack         = C_STACK_INC;
                end
                end
      4'b0010:  begin // swap
      4'b0010:  begin // swap
Line 399... Line 401...
  case (s_bus_t)
  case (s_bus_t)
    C_BUS_T_MATH_ROTATE:        s_T_pre = s_math_rotate;
    C_BUS_T_MATH_ROTATE:        s_T_pre = s_math_rotate;
    C_BUS_T_OPCODE:             s_T_pre = s_opcode[0+:8];  // push 8-bit value
    C_BUS_T_OPCODE:             s_T_pre = s_opcode[0+:8];  // push 8-bit value
    C_BUS_T_N:                  s_T_pre = s_N;
    C_BUS_T_N:                  s_T_pre = s_N;
    C_BUS_T_PRE:                s_T_pre = s_T_stack;
    C_BUS_T_PRE:                s_T_pre = s_T_stack;
    C_BUS_T_ADDER:              s_T_pre = s_T_adder;
    C_BUS_T_ADDER:              s_T_pre = s_T_adder[0+:8];
    C_BUS_T_COMPARE:            s_T_pre = {(8){s_T_compare}};
    C_BUS_T_COMPARE:            s_T_pre = {(8){s_T_compare}};
    C_BUS_T_INPORT:             s_T_pre = s_T_inport;
    C_BUS_T_INPORT:             s_T_pre = s_T_inport;
    C_BUS_T_LOGIC:              s_T_pre = s_T_logic;
    C_BUS_T_LOGIC:              s_T_pre = s_T_logic;
    C_BUS_T_MEM:                s_T_pre = s_memory;
    C_BUS_T_MEM:                s_T_pre = s_memory;
    default:                    s_T_pre = s_T;
    default:                    s_T_pre = s_T;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.