Files
CoCo3_Plus_MiSTer/rtl/ssc/ssc_tms7000_alu.sv
T
bholman cb40fed3b9 Introduce Coco 3 Plus for MiSTer
Add original-firmware Sound & Speech, four configurable Multi-Pak sockets,
bounded per-slot ROM allocation and a nine-page menu organized around devices
and media. Repair inherited clock/reset/CPU-memory/video paths and add explicit
conditional external-I/O timing contracts. Preserve native Main startup-file
ordering, saved layouts, stock-core separation and the coco3plus media profile.

Provide native Windows tool downloads, pinned ToolShed ROM assembly, fresh
Quartus builds, functional and fitted timing checks, reviewed release packaging
and passwordless SSH installation with backups. Retain original component
notices, document contribution copyright and keep SSC ROM inputs outside Git.

Validation: Quartus17.0.2 Build602 seed5, zero errors; 15 functional jobs,
368 both-corner timing scopes and eight tooling-integrity checks pass.
The renamed build reaches Disk BASIC, PRINT1+1 returns2 and SSC loads ready.
Physical cold power cycling and conditional board-delay assumptions remain
separate. Full original upstream histories are preserved before this single
consolidated implementation commit.
2026-11-18 16:00:45 -07:00

53 lines
2.6 KiB
Systemverilog

// Original Coco 3 Plus contributions: Copyright (c) 2026 Brian K. Holman.
// Original component notices/terms retained; see COPYRIGHT.md and LICENSING.md.
// SPDX-License-Identifier: BSD-3-Clause
// TMS7000 arithmetic/flags, from VCCPlus a8a84f22/MAME hap, Tim Lindner.
// Decimal/multiply use separate registered datapaths. Carry conventions: LICENSE.
module ssc_tms7000_alu(input wire [5:0] operation,
input wire [15:0] destination, input wire [7:0] source,status,
output reg [15:0] result, output reg [7:0] next_status,
output reg writeback, output reg branch, output reg [5:0] extra_cycles);
`include "ssc_tms7000_defs.vh"
reg [16:0] temp;
reg [8:0] flags_value;
reg set_flags,subtract;
always @* begin
temp=0;flags_value=0;result=0;next_status=status;writeback=1;branch=0;
extra_cycles=0;set_flags=1;subtract=0;
case(operation)
OP_MOV:temp={9'd0,source};
OP_AND:temp={9'd0,(destination[7:0]&source)};
OP_OR:temp={9'd0,(destination[7:0]|source)};
OP_XOR:temp={9'd0,(destination[7:0]^source)};
OP_BTJO,OP_BTJZ:begin
temp={9'd0,((operation==OP_BTJO?destination[7:0]:~destination[7:0])&source)};
writeback=0;branch=(temp!=0);extra_cycles=branch?6'd4:6'd2;
end
OP_ADD:temp={9'd0,destination[7:0]}+{9'd0,source};
OP_ADC:temp={9'd0,destination[7:0]}+{9'd0,source}+{16'd0,status[7]};
OP_SUB,OP_CMP:begin temp={9'd0,destination[7:0]}-{9'd0,source};subtract=1;writeback=(operation!=OP_CMP);end
OP_SBB:begin temp={9'd0,destination[7:0]}-{9'd0,source}-{16'd0,!status[7]};subtract=1;end
// MPY has its own registered datapath in the instruction engine.
OP_DEC:begin temp={9'd0,destination[7:0]}-17'd1;subtract=1;end
OP_INC:temp={9'd0,destination[7:0]}+17'd1;
OP_INV:temp={9'd0,~destination[7:0]};
OP_CLR:temp=0;
OP_XCHB:begin temp={9'd0,source};extra_cycles=1;end
OP_SWAP:begin temp={5'd0,destination[7:0],4'd0}|{13'd0,destination[7:4]};extra_cycles=3;end
OP_RR:temp={1'd0,destination[7:0],destination[0],destination[7:1]};
OP_RRC:temp={1'd0,destination[7:0],status[7],destination[7:1]};
OP_RL:temp={8'd0,destination[7:0],destination[7]};
OP_RLC:temp={8'd0,destination[7:0],status[7]};
OP_DJNZ:begin temp={9'd0,destination[7:0]}-17'd1;branch=(temp[15:0]!=0);extra_cycles=branch?6'd4:6'd2;set_flags=0;end
OP_DECD:begin temp={1'b0,destination}-17'd1;subtract=1;end
default:begin writeback=0;set_flags=0;end
endcase
result=temp[15:0];
flags_value=(operation==OP_MPY || operation==OP_DECD)?temp[16:8]:temp[8:0];
if(set_flags) begin
next_status={flags_value[8],flags_value[7],(flags_value[7:0]==0),status[4:0]};
if(subtract) next_status[7]=!flags_value[8];
end
end
endmodule